package base.IO流;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class 序列化 {
    public static void main(String[] args) throws IOException {
        File file = new File(".\\src\\base\\IO流\\girl.txt");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));

        Girlfriend g1 = new Girlfriend("小欣",19,"金陵");
        Girlfriend g2 = new Girlfriend("丹丹",18,"洛阳");
        Girlfriend g3 = new Girlfriend("扬子",20,"云梦泽");

        ArrayList<Girlfriend> list = new ArrayList<>();
        list.add(g1);
        list.add(g2);
        list.add(g3);

        oos.writeObject(list);
        oos.close();

    }
}
